Skip to content

--feature-type takes a 10x input with no types as gene expression (#127) - #128

Merged
Claptar merged 2 commits into
mainfrom
fix/127-untyped-feature-type
Nov 26, 2026
Merged

Claptar merged 2 commits into
mainfrom
fix/127-untyped-feature-type

Conversation

@Claptar

@Claptar Claptar commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #127.

adata convert … --feature-type 'Gene Expression' and --split-feature-types used to be refused on a Cell Ranger 2 .h5 and on an MTX folder whose features file has no type column (Cell Ranger 2's genes.tsv, older STARsolo's two-column features.tsv), though both convert fine without the flags. A pipeline that passes the same flags for any 10x input (nf-metacells) therefore had to inspect each input first.

Such an input holds gene expression alone, so its features are now taken as Gene Expression (option 1 of the issue):

  • --feature-type 'Gene Expression' keeps every feature and prints a warning saying so;
  • any other type is refused: No features of type 'Peaks'; Cell Ranger 2's layout records no feature types, so this file holds gene expression only.;
  • --split-feature-types writes one OUT.Gene_Expression.h5ad, as it does for a v3 file that holds gene expression only.

var gains no feature_types column, so the output equals the plain conversion, which is already checked against scanpy. Every mask is all-true, so the entry map stays the plain transpose, and reads and memory are unchanged.

A genes.tsv with a third column, often a Cell Ranger 3 features.tsv renamed for old Seurat on GEO, still refuses the flags. Its third column isn't read (scanpy ignores it too), and taking it as gene expression would keep antibodies. The message says to name the file features.tsv to filter on its types.

The change is in conversion/features.py::plan_targets, which takes an untyped reason from its caller (mtx.py, tenx.py); the two refusals are gone. Visium and Xenium share the path but are always v3. CellBender 0.2 run on Cell Ranger 2 input keeps that layout, so it gets the same behaviour. Parse doesn't take the flags.

Not in this PR, noted in STATUS.md: filtering an h5ad input on its feature_types column, the issue's lower-priority ask.

Changelog entry (for 0.17.7)

Changed

  • --feature-type and --split-feature-types take a 10x input with no feature types as gene expression (#127). A Cell Ranger 2 .h5, or a folder whose features file has no type column, holds gene expression alone. --feature-type "Gene Expression" now keeps every feature with a warning, rather than being refused; any other type is refused; and --split-feature-types writes one OUT.Gene_Expression output. So the same flags work on any 10x input.

Tests

  • test_the_type_flags_take_a_cell_ranger_2_file_as_gene_expression (h5) and test_the_type_flags_take_an_untyped_folder_as_gene_expression (mtx, over the cr2 and starsolo2col layouts) check the output against the plain conversion, along with the single output file and the warning. Both fail on main.
  • The refusal cases now expect the gene-expression message for another type, and check that no output of any name is written.
  • test_a_genes_tsv_with_a_third_column_refuses_the_type_flags, a GEO-prefixed folder, and test_cellbender_on_cell_ranger_2_input_takes_the_type_flags_as_gene_expression were added after review.
  • Full unit suite: 4029 passed, 9 skipped. The issue's reproduction works for both inputs, and --feature-type Peaks is refused.

🤖 Generated with Claude Code

--feature-type and --split-feature-types were refused on a Cell Ranger 2
.h5 and on a folder whose features file has no type column, though both
convert without them, so a pipeline had to inspect each 10x input before
it chose its flags. Such an input holds gene expression alone (Cell Ranger
2, older STARsolo), so plan_targets takes every feature as 'Gene
Expression' when the caller says why the types are missing: --feature-type
'Gene Expression' keeps every feature with a warning, any other type is
refused naming gene expression, and --split-feature-types writes one
OUT.Gene_Expression output. var gains no feature_types column, so the
output is the one the plain conversion gives; the entry map stays the
plain transpose.

Filtering an h5ad input on its feature_types column, the issue's lower
priority, is noted in STATUS.md as a follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T19:29:13.379114Z cbd85d6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

- A genes.tsv with a third column was called untyped, so --feature-type
  'Gene Expression' kept every feature of a Cell Ranger 3 features.tsv
  renamed genes.tsv (as GEO often serves them), antibodies included, and
  the warning said it had no types. Its third column is not read, as in
  scanpy, so the flags are refused there, saying to name the file
  features.tsv to filter on the types.
- The h5 message says "Cell Ranger 2's layout records no feature types",
  true of CellBender 0.2 run on Cell Ranger 2 input as well.
- Tests: values of var compared in the mtx test, a GEO-prefixed folder,
  CellBender on Cell Ranger 2 input, and a refusal checked to write no
  output of any name.
- Docs: .zarr outputs, the three-column case, 10x-mtx.md reflowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (py3.13)

3 836 tests  +11   3 824 ✅ +11   7m 55s ⏱️ - 1m 56s
    1 suites ± 0      12 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit fee6d45. ± Comparison against base commit 85723b6.

This pull request removes 3 and adds 14 tests. Note that renamed tests count towards both.
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[cr2-args1-records no feature types]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[starsolo2col-args0-records no feature types]
tests.test_tenx ‑ test_bad_cell_ranger_2_options_are_refused[extra1-records no feature types]
tests.test_cellbender ‑ test_cellbender_on_cell_ranger_2_input_takes_the_type_flags_as_gene_expression
tests.test_mtx ‑ test_a_genes_tsv_with_a_third_column_refuses_the_type_flags[flags0]
tests.test_mtx ‑ test_a_genes_tsv_with_a_third_column_refuses_the_type_flags[flags1]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[cr2-args1-No features of type 'Antibody Capture'; genes.tsv records no feature types, so this folder holds gene expression only.]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[starsolo2col-args0-No features of type 'Peaks'; features.tsv records no feature types, so this folder holds gene expression only.]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-cr2]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-geo-prefix]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-starsolo2col]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[split-cr2]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[split-geo-prefix]
…

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (py3.12)

3 836 tests  +11   3 824 ✅ +11   9m 15s ⏱️ + 3m 30s
    1 suites ± 0      12 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit fee6d45. ± Comparison against base commit 85723b6.

This pull request removes 3 and adds 14 tests. Note that renamed tests count towards both.
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[cr2-args1-records no feature types]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[starsolo2col-args0-records no feature types]
tests.test_tenx ‑ test_bad_cell_ranger_2_options_are_refused[extra1-records no feature types]
tests.test_cellbender ‑ test_cellbender_on_cell_ranger_2_input_takes_the_type_flags_as_gene_expression
tests.test_mtx ‑ test_a_genes_tsv_with_a_third_column_refuses_the_type_flags[flags0]
tests.test_mtx ‑ test_a_genes_tsv_with_a_third_column_refuses_the_type_flags[flags1]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[cr2-args1-No features of type 'Antibody Capture'; genes.tsv records no feature types, so this folder holds gene expression only.]
tests.test_mtx ‑ test_options_that_do_not_fit_are_refused[starsolo2col-args0-No features of type 'Peaks'; features.tsv records no feature types, so this folder holds gene expression only.]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-cr2]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-geo-prefix]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[feature-type-starsolo2col]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[split-cr2]
tests.test_mtx ‑ test_the_type_flags_take_an_untyped_folder_as_gene_expression[split-geo-prefix]
…

@Claptar
Claptar merged commit ac47bc1 into main Nov 26, 2026
13 checks passed
@Claptar Claptar mentioned this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

convert: --feature-type fails on 10x input without feature types (Cell Ranger 2 .h5, genes.tsv folders)

2 participants